<?php
include("template_top.php");
if($USER['iFirstLogin'] == 0){
	?>
    
<?php
$sql = "SELECT * FROM `tbTickets` WHERE `sDate` = :date";
$q = db::Query($sql, array(':date'=>date("n/j/Y")));
$ticketsToday = 0;
while($r = $q->fetch()){
	$ticketsToday ++;
}

$sql = "SELECT * FROM `tbTickets` WHERE `sDate` = :date AND `sTech` = :uname";
$q = db::Query($sql, array(':date'=>date("n/j/Y"), ':uname'=>$USER['sFname']." ".$USER['sLname']));
$myCount = 0;
while($r = $q->fetch()){
	$myCount ++;
}
?>
    <div class="info" style="background-image:none">
    <center><h1><?php $b = time(); $hour = date("g",$b); $m = date ("A", $b); if ($m == "AM") { if ($hour == 12) { echo "Good Evening, "; } elseif ($hour < 4) { echo "Good Evening, "; } elseif ($hour > 3) { echo "Good Morning, "; } } elseif ($m == "PM") { if ($hour == 12) { echo "Good Afternoon, "; } elseif ($hour < 5) { echo "Good Afternoon, "; } elseif ($hour > 4) { echo "Good Evening, "; } } ?><?php echo $USER['sFname'] ?>!</h1>
    <?php
	$file = file_get_contents("http://www.mydailyinsights.com/quote.asp");
	$temp = explode('<td width="100%">&nbsp;<font face="verdana" size="2"><P><B><FONT size=2 face=Verdana>', $file);
	$quote = explode('</FONT></B></P>', $temp[1]);
	$author = explode('</FONT></P></font></td>', $quote[2]);
	$author = explode('<P><FONT size=2 face=Verdana>', $author[0]);
	$author = $author[1];
	$quote = $quote[0];
	if($quote == ''){
		echo "<h3 style='border:none; margin:0px'>Men's best successes come after their disappointments.<br/>Henry Ward Beecher</h3>";
	}else{
		echo "<h3 style='border:none; margin:0px'>".$quote."<br/>".$author."</h3>";
	}
	?>
    </center>
    </div>
    <?php
}
$sql = "UPDATE `tbUsers` SET `iFirstLogin` = 1 WHERE `sUname` = :uname";
db::Query($sql, array(':uname'=>$USER['sUname']));
?>
<?php if($USER['sUname'] == ''){ ?>
<h1>Blog</h1>
<br/>
<!--
<?php // CODE BELOW IS FOR EMERGENCY ANNOUNCEMENTS ?>
<div style="background-color:#F00; color:#FFF; border:5px solid #000; margin-bottom:5px; background-image:url(images/birthday.gif); background-position:center 55px; background-repeat:no-repeat" align="center">
	<h4 style="font-size:50px; color:#FFF; border:none; margin-bottom:0px">HAPPY BIRTHDAY PORTAL!!!</h4>
	<div align="center" style="font-size:18px; font-weight:bold; padding-bottom:15px">
	<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    Today the Portal turns 1.<br/><br/>
    It has been a great year and hope that many more are to come!<br/><br/>
    Want to see what the first portal looked like?<br/><br/>
    <a href="http://192.168.30.40/NEW/" target="_blank" style="color:#000">Click Here</a>
	</div>
</div>
-->
<?php
$sql = "SELECT * FROM `tbAnnouncements`";
$q = db::Query($sql);
while($row = $q->fetch()){
	if(strtotime($row['sExpireDate']." ".$row['sExpireTime']) > time() or $row['sExpireDate'] == ''){
	?>
    <div>
		<h4 style="font-size:15px; color:#000; border:none; margin-bottom:0px; padding-left:0px;"><?php echo $row['sTitle'] ?> - Posted By: <?php echo $row['sSubmit'] ?></h4>
		<p style="font-size:12px; font-weight:bold; padding-bottom:15px">
			<?php echo $row['sAnnouncement'] ?>
		</p>
	</div>
	<?php
	}
}
?>
<?php }else{ ?>
<?php if(isset($_POST['question1'])){ ?>
<?php
$body = "Survey Submission<br/><br/>";
$body .= "Section 1 - 1 = Strongly Agree / 10 = Strongly Disagree<br/>";
$body .= "1. The Portal is very easy to navigate. - ".$_POST['question1']."<br/>";
$body .= "2. The Portal is neatly organized and finding information is simple. - ".$_POST['question2']."<br/>";
$body .= "3. The Portal is very welcoming and inviting. - ".$_POST['question3']."<br/>";
$body .= "4. The look and feel of the Portal is attractive yet professional. - ".$_POST['question4']."<br/>";
$body .= "5. The Portal makes my daily tasks easier. - ".$_POST['question5']."<br/><br/><br/>";
$body .= "Section 2<br/>";
$body .= "1. In terms of usability, how could we make the Portal easier to find things and navigate?  - ".$_POST['sec2ques1']."<br/><br/>";
$body .= "2. If you could change anything on the Portal, what would it be and how would you change it?  - ".$_POST['sec2ques2']."<br/><br/>";
$body .= "3. Are there any comments or suggestions that you have for the Portal team?  - ".$_POST['sec2ques3']."<br/>";

sendEmail("kpeterson5@edison.edu", "New Suvery Submission", $body);
$sql = "INSERT INTO `tbSurvey` VALUES(:uname)";
db::Query($sql, array(':uname'=>$USER['sUname']));
?>
<h1>How Are We Doing?</h1>
<br/>
Thank you for participating in the survey!<br/><br/>Your answers will help us to help make the Portal simpler and easier to use!
<?php }else{ ?>
<?php
$sql = "SELECT * FROM `tbSurvey` WHERE `sUname` = :uname";
$q = db::Query($sql, array(':uname'=>$USER['sUname']));
$row = $q->fetch();
if($row['sUname'] == NULL){
?>
<form action="index.php" method="post">
<h1>How Are We Doing?</h1>
<br/>
<center>
Please take a moment to fill out the survey below so we can better assist you.<br/>All answers are confidential and your name and/or username is not tied to the results.<br/>Please be as honest as possible.<br/><br/>
</center>
<div id="section1">
<h4>Section 1</h4>
<table width="100%">
	<tr>
    	<td>
        </td>
        <td width="50" align="center">
        Strongly Agree
        </td>
    	<td width="50">
        </td>
    	<td width="50">
        </td>
    	<td width="50">
        </td>
    	<td width="50" align="center">
        <br/>Neutral
        </td>
    	<td width="50">
        </td>
    	<td width="50">
        </td>
    	<td width="50">
        </td>
    	<td width="50">
        </td>
    	<td width="50" align="center">
        Strongly Disagree
        </td>
    </tr>
	<tr>
    	<td>
        1. The Portal is very easy to navigate.
        </td>
        <?php
        $c = 1;
		while($c <= 10){
		?>
        <td align="center">
        <input type="radio" name="question1" value="<?php echo $c ?>" />
        </td>
        <?php
		$c ++;
		}
		?>
	</tr>
	<tr>
    	<td>
        2. The Portal is neatly organized and finding information is simple.
        </td>
        <?php
        $c = 1;
		while($c <= 10){
		?>
        <td align="center">
        <input type="radio" name="question2" value="<?php echo $c ?>" />
        </td>
        <?php
		$c ++;
		}
		?>
	</tr>
	<tr>
    	<td>
        3. The Portal is very welcoming and inviting.
        </td>
        <?php
        $c = 1;
		while($c <= 10){
		?>
        <td align="center">
        <input type="radio" name="question3" value="<?php echo $c ?>" />
        </td>
        <?php
		$c ++;
		}
		?>
	</tr>
	<tr>
    	<td>
        4. The look and feel of the Portal is attractive yet professional.
        </td>
        <?php
        $c = 1;
		while($c <= 10){
		?>
        <td align="center">
        <input type="radio" name="question4" value="<?php echo $c ?>" />
        </td>
        <?php
		$c ++;
		}
		?>
	</tr>
	<tr>
    	<td>
        5. The Portal makes my daily tasks easier.
        </td>
        <?php
        $c = 1;
		while($c <= 10){
		?>
        <td align="center">
        <input type="radio" name="question5" value="<?php echo $c ?>" />
        </td>
        <?php
		$c ++;
		}
		?>
	</tr>
</table>
</div>
<br/><br/>
<div id="section2">
<h4>Section 2</h4>
1. In terms of usability, how could we make the Portal easier to find things and navigate?
<textarea name="sec2ques1" style="width:99%; height:100px"></textarea>
<br/><br/>
2. If you could change anything on the Portal, what would it be and how would you change it?
<textarea name="sec2ques2" style="width:99%; height:100px"></textarea>
<br/><br/>
3. Are there any comments or suggestions that you have for the Portal team?
<textarea name="sec2ques3" style="width:99%; height:100px"></textarea>
</div>
<br/><br/>
<input type="submit" value="Submit Survey :)" style="width:100%; height:50px; font-weight:bold; font-size:30px" />
</form>
<?php }else{ ?>
<h1>Blog</h1>
<br/>
<!--
<?php // CODE BELOW IS FOR EMERGENCY ANNOUNCEMENTS ?>
<div style="background-color:#F00; color:#FFF; border:5px solid #000; margin-bottom:5px; background-image:url(images/birthday.gif); background-position:center 55px; background-repeat:no-repeat" align="center">
	<h4 style="font-size:50px; color:#FFF; border:none; margin-bottom:0px">HAPPY BIRTHDAY PORTAL!!!</h4>
	<div align="center" style="font-size:18px; font-weight:bold; padding-bottom:15px">
	<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    Today the Portal turns 1.<br/><br/>
    It has been a great year and hope that many more are to come!<br/><br/>
    Want to see what the first portal looked like?<br/><br/>
    <a href="http://192.168.30.40/NEW/" target="_blank" style="color:#000">Click Here</a>
	</div>
</div>
-->
<?php
$sql = "SELECT * FROM `tbAnnouncements`";
$q = db::Query($sql);
while($row = $q->fetch()){
	if(strtotime($row['sExpireDate']." ".$row['sExpireTime']) > time() or $row['sExpireDate'] == ''){
	?>
    <div>
		<h4 style="font-size:15px; color:#000; border:none; margin-bottom:0px; padding-left:0px;"><?php echo $row['sTitle'] ?> - Posted By: <?php echo $row['sSubmit'] ?></h4>
		<p style="font-size:12px; font-weight:bold; padding-bottom:15px">
			<?php echo nl2br($row['sAnnouncement']) ?>
		</p>
	</div>
	<?php
	}
}
?>
<?php } ?>
<?php } ?>
<?php } ?>
<?php
include("template_bot.php");
?>